package com.internal.Search.client;

import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.SuggestOracle;

public class SuggestProOrcale extends SuggestOracle {

	@Override
	public void requestSuggestions(Request request, Callback callback) {
		SearchService.Util.getInstance().getProSuggest(request, new ProSuggestCallback(request,callback));

	}

	class ProSuggestCallback implements AsyncCallback<ProSuggestion> {

		private final SuggestOracle.Request req;
		private final SuggestOracle.Callback callback;

		public ProSuggestCallback(final SuggestOracle.Request _req,
				final SuggestOracle.Callback _callback) {
			this.req = _req;
			this.callback = _callback;
		}

		@Override
		public void onFailure(Throwable caught) {
			this.callback.onSuggestionsReady(this.req, new SuggestOracle.Response());

		}

		@Override
		public void onSuccess(ProSuggestion result) {
			this.callback.onSuggestionsReady(this.req, result.getResponse());

		}

	}

}
